<?php
/**
 * 订单支付服务
 */

namespace polymerize\order\service;

use app\common\InstanceTrait;
use Exception;
use polymerize\order\module\pay\PayOrderQuery;
use polymerize\order\module\pay\PayOrderQueryByCz;
use polymerize\order\module\pay\PayOrderQueryByProduct;
use polymerize\order\module\pay\PayOrderQueryByVipcart;
use polymerize\order\module\pay\PayVip;
use polymerize\order\module\pay\ProductPay;
use polymerize\order\module\pay\ProductPayContinue;
use polymerize\order\module\pay\RechargeDiscountPay;
use polymerize\order\module\pay\VipcartPay;

class PayService
{
    use InstanceTrait;

    /**
     * 订单支付结果查询
     *
     * @param string $orderNo
     * @param int    $payType
     * @return array
     * @throws Exception
     */
    public function payOrderQuery(string $orderNo, int $payType): array
    {
        return PayOrderQuery::getInstance()->payOrderQuery($orderNo, $payType);
    }

    /**
     * VIP支付购买
     *
     * @param int    $uid
     * @param int    $osType
     * @param string $vipType
     * @param int    $payType
     * @param int    $disposableGoods
     * @return array
     */
    public function payVip(int $uid, int $osType, string $vipType, int $payType, int $disposableGoods): array
    {
        return PayVip::getInstance()->payVip($uid, $osType, $vipType, $payType, $disposableGoods);
    }

    /**
     * 购买充值卡
     *
     * @param int $uid
     * @param int $osType
     * @param int $rechargeDiscountId
     * @return array
     */
    public function rechargeDiscountPay(int $uid, int $osType, int $rechargeDiscountId): array
    {
        return RechargeDiscountPay::getInstance()->rechargeDiscountPay($uid, $osType, $rechargeDiscountId);
    }

    /**
     * 购买充值卡支付结果查询
     *
     * @param string $orderNo
     * @return array
     * @throws Exception
     */
    public function payOrderQueryByCz(string $orderNo): array
    {
        return PayOrderQueryByCz::getInstance()->payOrderQueryByCz($orderNo);
    }

    /**
     * 购买会员卡
     *
     * @param int    $uid
     * @param int    $useType
     * @param string $useMobile
     * @param int    $deliveryType
     * @param string $deliveryAddress
     * @param string $deliveryMobile
     * @param int    $goodsId
     * @param int    $goodsSpecificationId
     * @param string $goodsName
     * @param string $goodsSpecificationName
     * @param int    $rechargePrice
     * @param int    $discountPrice
     * @param int    $payType
     * @return array
     */
    public function vipcartPay(int $uid, int $useType, string $useMobile, int $deliveryType, string $deliveryAddress, string $deliveryMobile, int $goodsId, int $goodsSpecificationId, string $goodsName, string $goodsSpecificationName, int $rechargePrice, int $discountPrice, int $payType, string $customerRemark): array
    {
        return VipcartPay::getInstance()->vipcartPay($uid, $useType, $useMobile, $deliveryType, $deliveryAddress, $deliveryMobile, $goodsId, $goodsSpecificationId, $goodsName, $goodsSpecificationName, $rechargePrice, $discountPrice, $payType, $customerRemark);
    }

    /**
     * 购买会员卡支付结果查询
     *
     * @param string $orderNo
     * @return array
     * @throws Exception
     */
    public function payOrderQueryByVipcart(string $orderNo): array
    {
        return PayOrderQueryByVipcart::getInstance()->payOrderQueryByVipcart($orderNo);
    }

    /**
     * 购买产品
     *
     * @param int    $uid
     * @param int    $deliveryType
     * @param string $deliveryAddress
     * @param string $deliveryMobile
     * @param string $deliveryTime
     * @param string $customerRemark
     * @param string $orderProductInfo
     * @param int    $rechargePrice
     * @param int    $discountPrice
     * @param int    $payType
     * @return array
     */
    public function productPay(int $uid, int $deliveryType, string $deliveryAddress, string $deliveryMobile, string $deliveryTime, string $customerRemark, string $orderProductInfo, int $rechargePrice, int $discountPrice, int $payType): array
    {
        return ProductPay::getInstance()->productPay($uid, $deliveryType, $deliveryAddress, $deliveryMobile, $deliveryTime, $customerRemark, $orderProductInfo, $rechargePrice, $discountPrice, $payType);
    }

    /**
     * 购买产品支付结果查询
     *
     * @param string $orderNo
     * @return array
     * @throws Exception
     */
    public function payOrderQueryByProduct(string $orderNo): array
    {
        return PayOrderQueryByProduct::getInstance()->payOrderQueryByProduct($orderNo);
    }

    /**
     * 购买产品-继续支付
     *
     * @param string $orderNo
     * @param int    $uid
     * @return array
     */
    public function productPayContinue(string $orderNo, int $uid): array
    {
        return ProductPayContinue::getInstance()->productPayContinue($orderNo, $uid);
    }

}